home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11553 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: vixen.cso.uiuc.edu!usenet
  2. From: n-dade@uiuc.edu
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: works in Borland but not in Microsuck Visual C++
  5. Date: 15 Mar 1996 01:19:41 GMT
  6. Organization: University of Illinois at Urbana
  7. Message-ID: <4iagjd$nli@vixen.cso.uiuc.edu>
  8. References: <4ia6h8$jes@news.vanderbilt.edu>
  9. Reply-To: n-dade@uiuc.edu
  10. NNTP-Posting-Host: homer.apr.uiuc.edu
  11. X-Newsreader: IBM NewsReader/2 v1.2
  12.  
  13. In <4ia6h8$jes@news.vanderbilt.edu>, haseltbt@ctrvax.vanderbilt.edu (Bennett Haselton) writes:
  14. >    Dear Abby,
  15. >
  16. >        The following program was written in completely standard C++ 
  17. >and should be portable across platforms.  However, it only performs as 
  18. >expected (i.e. sends two copies of 4 to the standard out stream) in Borland 
  19. >C++; when compiled in MicroSUCK Visual C++, it outputs 4 followed by a random 
  20. >integer in the thousands.
  21.  
  22. Actually it performs as well it is can; the code is wrong.
  23.  
  24.  
  25. >struct person* matchPerson( struct person* psnPtr )
  26. >{
  27. >    struct person* ansPtr;
  28. >    ansPtr->age = psnPtr->age;
  29. >    cout << ansPtr->age;
  30. >    cout << ansPtr->age;
  31. >    return ansPtr;                         
  32. >};
  33.  
  34. You use *ansPtr ("ansPtr->age = ...") but ansPtr has not been set to point
  35. to anything in particular! Where that int goes nobody knows.
  36.  
  37.  
  38. >i was using version 1.0 of Visual C++; i have no knowledge of whether later 
  39. >Microsuck compilers are capable of handling a program like this properly.  
  40. >Please avoid buying their products whenever possible if you have not already 
  41. >resolved to do so.
  42.  
  43. Please avoid using uninitialized pointers. :-)
  44. I do have to agree about MS VC++ in a general sense: there is better out there
  45. (ie IBM's Visual Age C++ is very sweet IMHO).
  46.  
  47. -Nicolas Dade / n9rzb / nicolas-dade@uiuc.edu
  48.  
  49.